<?php
/**
 * 关于生成二维码 小程序码
 * */
namespace app\common\service;
use app\common\model\UserCoupon as uc;
use think\Service;

class CouponService
{
		function getUserCoupon($args = [] , $money = 0){
			    $w[] = ['is_use','=',0];
			    $w[] = ['end_time','>=',time()];
			    $w[] = ['user_id','=',$args['uid']];
				$res = uc::where($w)->select();
				if($res){
					 $res = $res->toArray();
				}
				foreach($res as &$v){
						if($v['require_type'] == 0){
							$v['can_use'] = ($v['require_money'] <= $money) ? 1 : 0;
						}
						if($v['require_type'] == 1){
							  $v['can_use'] = 1;
						}

				}
				
				return $res;
		}
}